{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. [检查索引](#%E6%A3%80%E6%9F%A5%E7%B4%A2%E5%BC%95)\n",
    "2. [生成笛卡尔积（数据库的full join操作）](#%E7%94%9F%E6%88%90%E7%AC%9B%E5%8D%A1%E5%B0%94%E7%A7%AF%EF%BC%88%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84full-join%E6%93%8D%E4%BD%9C%EF%BC%89)\n",
    "3. [索引爆炸（生成排列组合）](#%E7%B4%A2%E5%BC%95%E7%88%86%E7%82%B8%EF%BC%88%E7%94%9F%E6%88%90%E6%8E%92%E5%88%97%E7%BB%84%E5%90%88%EF%BC%89)\n",
    "4. [不同索引情况下的值填充](#%E4%B8%8D%E5%90%8C%E7%B4%A2%E5%BC%95%E6%83%85%E5%86%B5%E4%B8%8B%E7%9A%84%E5%80%BC%E5%A1%AB%E5%85%85)\n",
    "5. [使用其它DataFrame添加列](#%E4%BD%BF%E7%94%A8%E5%85%B6%E5%AE%83DataFrame%E6%B7%BB%E5%8A%A0%E5%88%97)\n",
    "6. [高亮显示每列最大值](#%E9%AB%98%E4%BA%AE%E6%98%BE%E7%A4%BA%E6%AF%8F%E5%88%97%E6%9C%80%E5%A4%A7%E5%80%BC)\n",
    "7. [使用方法链复制idmax](#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95%E9%93%BE%E5%A4%8D%E5%88%B6idmax)\n",
    "8. [寻找出现最多的最大值（哪一列在行上最大值的次数最多）](#%E5%AF%BB%E6%89%BE%E5%87%BA%E7%8E%B0%E6%9C%80%E5%A4%9A%E7%9A%84%E6%9C%80%E5%A4%A7%E5%80%BC%EF%BC%88%E5%93%AA%E4%B8%80%E5%88%97%E5%9C%A8%E8%A1%8C%E4%B8%8A%E6%9C%80%E5%A4%A7%E5%80%BC%E7%9A%84%E6%AC%A1%E6%95%B0%E6%9C%80%E5%A4%9A%EF%BC%89)\n",
    "9. [ 扩展内容，关于.cumsum().cumsum()案例的详解](#%E6%89%A9%E5%B1%95%E5%86%85%E5%AE%B9%EF%BC%8C%E5%85%B3%E4%BA%8E.cumsum().cumsum()%E6%A1%88%E4%BE%8B%E7%9A%84%E8%AF%A6%E8%A7%A3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 检查索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['INSTNM', 'CITY', 'STABBR', 'HBCU', 'MENONLY', 'WOMENONLY', 'RELAFFIL',\n",
       "       'SATVRMID', 'SATMTMID', 'DISTANCEONLY', 'UGDS', 'UGDS_WHITE',\n",
       "       'UGDS_BLACK', 'UGDS_HISP', 'UGDS_ASIAN', 'UGDS_AIAN', 'UGDS_NHPI',\n",
       "       'UGDS_2MOR', 'UGDS_NRA', 'UGDS_UNKN', 'PPTUG_EF', 'CURROPER', 'PCTPELL',\n",
       "       'PCTFLOAN', 'UG25ABV', 'MD_EARN_WNE_P10', 'GRAD_DEBT_MDN_SUPP'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = pd.read_csv('data/college.csv')\n",
    "columns = college.columns\n",
    "columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['INSTNM', 'CITY', 'STABBR', 'HBCU', 'MENONLY', 'WOMENONLY',\n",
       "       'RELAFFIL', 'SATVRMID', 'SATMTMID', 'DISTANCEONLY', 'UGDS',\n",
       "       'UGDS_WHITE', 'UGDS_BLACK', 'UGDS_HISP', 'UGDS_ASIAN', 'UGDS_AIAN',\n",
       "       'UGDS_NHPI', 'UGDS_2MOR', 'UGDS_NRA', 'UGDS_UNKN', 'PPTUG_EF',\n",
       "       'CURROPER', 'PCTPELL', 'PCTFLOAN', 'UG25ABV', 'MD_EARN_WNE_P10',\n",
       "       'GRAD_DEBT_MDN_SUPP'], dtype=object)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'WOMENONLY'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns[5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['CITY', 'SATMTMID', 'UGDS'], dtype='object')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns[[1,8,10]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['PPTUG_EF', 'CURROPER', 'PCTPELL'], dtype='object')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns[-7:-4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('CITY', 'WOMENONLY', 0)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns.min(), columns.max(), columns.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['INSTNM_A', 'CITY_A', 'STABBR_A', 'HBCU_A', 'MENONLY_A', 'WOMENONLY_A',\n",
       "       'RELAFFIL_A', 'SATVRMID_A', 'SATMTMID_A', 'DISTANCEONLY_A', 'UGDS_A',\n",
       "       'UGDS_WHITE_A', 'UGDS_BLACK_A', 'UGDS_HISP_A', 'UGDS_ASIAN_A',\n",
       "       'UGDS_AIAN_A', 'UGDS_NHPI_A', 'UGDS_2MOR_A', 'UGDS_NRA_A',\n",
       "       'UGDS_UNKN_A', 'PPTUG_EF_A', 'CURROPER_A', 'PCTPELL_A', 'PCTFLOAN_A',\n",
       "       'UG25ABV_A', 'MD_EARN_WNE_P10_A', 'GRAD_DEBT_MDN_SUPP_A'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns + '_A' # 每个元素都加"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ True, False,  True,  True,  True,  True,  True,  True,  True,\n",
       "       False,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "        True,  True,  True, False,  True,  True,  True,  True,  True])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns > 'G' # 返回每个元素的比较结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "Index does not support mutable operations",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-10-fc824787a439>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mcolumns\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'city'\u001b[0m \u001b[1;31m# 索引是不能写的，上面+是返回一个新的索引。\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36m__setitem__\u001b[1;34m(self, key, value)\u001b[0m\n\u001b[0;32m   3907\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3908\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__setitem__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3909\u001b[1;33m         \u001b[1;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Index does not support mutable operations\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3910\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3911\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__getitem__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: Index does not support mutable operations"
     ]
    }
   ],
   "source": [
    "columns[1] = 'city' # 索引是不能写的，上面+是返回一个新的索引。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['INSTNM', 'CITY', 'STABBR', 'HBCU'], dtype='object')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c1 = columns[:4]\n",
    "c1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['STABBR', 'HBCU', 'MENONLY'], dtype='object')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c2 = columns[2:5]\n",
    "c2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['CITY', 'HBCU', 'INSTNM', 'MENONLY', 'STABBR'], dtype='object')"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c1.union(c2) # 并集操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['CITY', 'HBCU', 'INSTNM', 'MENONLY', 'STABBR'], dtype='object')"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c1 | c2 # 与union等价。如果是&就是求交集。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['CITY', 'INSTNM', 'MENONLY'], dtype='object')"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c1.symmetric_difference(c2) # 对称差，即交集减去并集。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['CITY', 'INSTNM', 'MENONLY'], dtype='object')"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c1 ^ c2 # symmetric_difference"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 生成笛卡尔积（数据库的full join操作）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0\n",
       "a    1\n",
       "a    2\n",
       "b    3\n",
       "dtype: int32"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 = pd.Series(index=list('aaab'), data=np.arange(4)) # 生成一个简单的Series，指定索引和值。\n",
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "c    0\n",
       "a    1\n",
       "b    2\n",
       "a    3\n",
       "b    4\n",
       "b    5\n",
       "dtype: int32"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2 = pd.Series(index=list('cababb'), data=np.arange(6))\n",
    "s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    1.0\n",
       "a    3.0\n",
       "a    2.0\n",
       "a    4.0\n",
       "a    3.0\n",
       "a    5.0\n",
       "b    5.0\n",
       "b    7.0\n",
       "b    8.0\n",
       "c    NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "以a为例：\n",
    "0 + 1 = 1\n",
    "0 + 3 = 3\n",
    "1 + 1 = 2\n",
    "1 + 3 = 4\n",
    "所以结果里索引a对应4个值。\n",
    "'''\n",
    "s1 + s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0.0\n",
       "a    1.0\n",
       "a    2.0\n",
       "a    1.0\n",
       "a    2.0\n",
       "a    3.0\n",
       "a    2.0\n",
       "a    3.0\n",
       "a    4.0\n",
       "b    6.0\n",
       "b    7.0\n",
       "b    7.0\n",
       "b    8.0\n",
       "c    NaN\n",
       "dtype: float64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 = pd.Series(index=list('aaabbc'), data=np.arange(6)) # 因为s2没有c，所以结果c是空值NaN。\n",
    "s2 = pd.Series(index=list('aaabb'), data=np.arange(5))\n",
    "s1 + s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    2\n",
       "a    3\n",
       "a    4\n",
       "a    3\n",
       "a    4\n",
       "a    5\n",
       "a    4\n",
       "a    5\n",
       "a    6\n",
       "b    3\n",
       "b    4\n",
       "b    4\n",
       "b    5\n",
       "dtype: int32"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 = pd.Series(index=list('aaabb'), data=np.arange(5))\n",
    "s2 = pd.Series(index=list('bbaaa'), data=np.arange(5))\n",
    "s1 + s2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 索引爆炸（生成排列组合）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UNIQUE_ID</th>\n",
       "      <th>POSITION_TITLE</th>\n",
       "      <th>DEPARTMENT</th>\n",
       "      <th>BASE_SALARY</th>\n",
       "      <th>EMPLOYMENT_TYPE</th>\n",
       "      <th>GENDER</th>\n",
       "      <th>EMPLOYMENT_STATUS</th>\n",
       "      <th>HIRE_DATE</th>\n",
       "      <th>JOB_DATE</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RACE</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Hispanic/Latino</th>\n",
       "      <td>0</td>\n",
       "      <td>ASSISTANT DIRECTOR (EX LVL)</td>\n",
       "      <td>Municipal Courts Department</td>\n",
       "      <td>121862.0</td>\n",
       "      <td>Full Time</td>\n",
       "      <td>Female</td>\n",
       "      <td>Active</td>\n",
       "      <td>2006-06-12</td>\n",
       "      <td>2012-10-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Hispanic/Latino</th>\n",
       "      <td>1</td>\n",
       "      <td>LIBRARY ASSISTANT</td>\n",
       "      <td>Library</td>\n",
       "      <td>26125.0</td>\n",
       "      <td>Full Time</td>\n",
       "      <td>Female</td>\n",
       "      <td>Active</td>\n",
       "      <td>2000-07-19</td>\n",
       "      <td>2010-09-18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>White</th>\n",
       "      <td>2</td>\n",
       "      <td>POLICE OFFICER</td>\n",
       "      <td>Houston Police Department-HPD</td>\n",
       "      <td>45279.0</td>\n",
       "      <td>Full Time</td>\n",
       "      <td>Male</td>\n",
       "      <td>Active</td>\n",
       "      <td>2015-02-03</td>\n",
       "      <td>2015-02-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>White</th>\n",
       "      <td>3</td>\n",
       "      <td>ENGINEER/OPERATOR</td>\n",
       "      <td>Houston Fire Department (HFD)</td>\n",
       "      <td>63166.0</td>\n",
       "      <td>Full Time</td>\n",
       "      <td>Male</td>\n",
       "      <td>Active</td>\n",
       "      <td>1982-02-08</td>\n",
       "      <td>1991-05-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>White</th>\n",
       "      <td>4</td>\n",
       "      <td>ELECTRICIAN</td>\n",
       "      <td>General Services Department</td>\n",
       "      <td>56347.0</td>\n",
       "      <td>Full Time</td>\n",
       "      <td>Male</td>\n",
       "      <td>Active</td>\n",
       "      <td>1989-06-19</td>\n",
       "      <td>1994-10-22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 UNIQUE_ID               POSITION_TITLE  \\\n",
       "RACE                                                      \n",
       "Hispanic/Latino          0  ASSISTANT DIRECTOR (EX LVL)   \n",
       "Hispanic/Latino          1            LIBRARY ASSISTANT   \n",
       "White                    2               POLICE OFFICER   \n",
       "White                    3            ENGINEER/OPERATOR   \n",
       "White                    4                  ELECTRICIAN   \n",
       "\n",
       "                                    DEPARTMENT  BASE_SALARY EMPLOYMENT_TYPE  \\\n",
       "RACE                                                                          \n",
       "Hispanic/Latino    Municipal Courts Department     121862.0       Full Time   \n",
       "Hispanic/Latino                        Library      26125.0       Full Time   \n",
       "White            Houston Police Department-HPD      45279.0       Full Time   \n",
       "White            Houston Fire Department (HFD)      63166.0       Full Time   \n",
       "White              General Services Department      56347.0       Full Time   \n",
       "\n",
       "                 GENDER EMPLOYMENT_STATUS   HIRE_DATE    JOB_DATE  \n",
       "RACE                                                               \n",
       "Hispanic/Latino  Female            Active  2006-06-12  2012-10-13  \n",
       "Hispanic/Latino  Female            Active  2000-07-19  2010-09-18  \n",
       "White              Male            Active  2015-02-03  2015-02-03  \n",
       "White              Male            Active  1982-02-08  1991-05-25  \n",
       "White              Male            Active  1989-06-19  1994-10-22  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employee = pd.read_csv('data/employee.csv', index_col='RACE')\n",
    "employee.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "salary1 = employee['BASE_SALARY']\n",
    "salary2 = employee['BASE_SALARY']\n",
    "salary1 is salary2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "salary1 = employee['BASE_SALARY'].copy()\n",
    "salary2 = employee['BASE_SALARY'].copy()\n",
    "salary1 is salary2 # 复制后在内存里就不在同一区域了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RACE\n",
       "American Indian or Alaskan Native    78355.0\n",
       "American Indian or Alaskan Native    26125.0\n",
       "American Indian or Alaskan Native    98536.0\n",
       "American Indian or Alaskan Native        NaN\n",
       "American Indian or Alaskan Native    55461.0\n",
       "Name: BASE_SALARY, dtype: float64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "salary1 = salary1.sort_index()\n",
    "salary1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RACE\n",
       "Hispanic/Latino    121862.0\n",
       "Hispanic/Latino     26125.0\n",
       "White               45279.0\n",
       "White               63166.0\n",
       "White               56347.0\n",
       "Name: BASE_SALARY, dtype: float64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "salary2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "salary_add = salary1 + salary2 # 结果会去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RACE\n",
       "American Indian or Alaskan Native    138702.0\n",
       "American Indian or Alaskan Native    156710.0\n",
       "American Indian or Alaskan Native    176891.0\n",
       "American Indian or Alaskan Native    159594.0\n",
       "American Indian or Alaskan Native    127734.0\n",
       "Name: BASE_SALARY, dtype: float64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "salary_add.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2000, 2000, 1175424, 2000)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 自己加自己，比如a有1，2两个值，那么加了之后就有1，2，3，4四个值。\n",
    "salary_add1 = salary1 + salary1\n",
    "len(salary1), len(salary2), len(salary_add), len(salary_add1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Black or African American            700\n",
       "White                                665\n",
       "Hispanic/Latino                      480\n",
       "Asian/Pacific Islander               107\n",
       "NaN                                   35\n",
       "American Indian or Alaskan Native     11\n",
       "Others                                 2\n",
       "Name: RACE, dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index_vc = salary1.index.value_counts(dropna=False)\n",
    "index_vc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1175424"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index_vc.pow(2).sum() # 每个值平方然后求和"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 不同索引情况下的值填充"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>yearID</th>\n",
       "      <th>stint</th>\n",
       "      <th>teamID</th>\n",
       "      <th>lgID</th>\n",
       "      <th>G</th>\n",
       "      <th>AB</th>\n",
       "      <th>R</th>\n",
       "      <th>H</th>\n",
       "      <th>2B</th>\n",
       "      <th>3B</th>\n",
       "      <th>...</th>\n",
       "      <th>RBI</th>\n",
       "      <th>SB</th>\n",
       "      <th>CS</th>\n",
       "      <th>BB</th>\n",
       "      <th>SO</th>\n",
       "      <th>IBB</th>\n",
       "      <th>HBP</th>\n",
       "      <th>SH</th>\n",
       "      <th>SF</th>\n",
       "      <th>GIDP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>playerID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>altuvjo01</th>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>HOU</td>\n",
       "      <td>AL</td>\n",
       "      <td>158</td>\n",
       "      <td>660</td>\n",
       "      <td>85</td>\n",
       "      <td>225</td>\n",
       "      <td>47</td>\n",
       "      <td>3</td>\n",
       "      <td>...</td>\n",
       "      <td>59.0</td>\n",
       "      <td>56.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>36</td>\n",
       "      <td>53.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cartech02</th>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>HOU</td>\n",
       "      <td>AL</td>\n",
       "      <td>145</td>\n",
       "      <td>507</td>\n",
       "      <td>68</td>\n",
       "      <td>115</td>\n",
       "      <td>21</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>88.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>56</td>\n",
       "      <td>182.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>12.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>castrja01</th>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>HOU</td>\n",
       "      <td>AL</td>\n",
       "      <td>126</td>\n",
       "      <td>465</td>\n",
       "      <td>43</td>\n",
       "      <td>103</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>56.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>34</td>\n",
       "      <td>151.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>corpoca01</th>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>HOU</td>\n",
       "      <td>AL</td>\n",
       "      <td>55</td>\n",
       "      <td>170</td>\n",
       "      <td>22</td>\n",
       "      <td>40</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>19.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>14</td>\n",
       "      <td>37.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>dominma01</th>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>HOU</td>\n",
       "      <td>AL</td>\n",
       "      <td>157</td>\n",
       "      <td>564</td>\n",
       "      <td>51</td>\n",
       "      <td>121</td>\n",
       "      <td>17</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>57.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>29</td>\n",
       "      <td>125.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>23.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           yearID  stint teamID lgID    G   AB   R    H  2B  3B  ...   RBI  \\\n",
       "playerID                                                         ...         \n",
       "altuvjo01    2014      1    HOU   AL  158  660  85  225  47   3  ...  59.0   \n",
       "cartech02    2014      1    HOU   AL  145  507  68  115  21   1  ...  88.0   \n",
       "castrja01    2014      1    HOU   AL  126  465  43  103  21   2  ...  56.0   \n",
       "corpoca01    2014      1    HOU   AL   55  170  22   40   6   0  ...  19.0   \n",
       "dominma01    2014      1    HOU   AL  157  564  51  121  17   0  ...  57.0   \n",
       "\n",
       "             SB   CS  BB     SO  IBB  HBP   SH   SF  GIDP  \n",
       "playerID                                                   \n",
       "altuvjo01  56.0  9.0  36   53.0  7.0  5.0  1.0  5.0  20.0  \n",
       "cartech02   5.0  2.0  56  182.0  6.0  5.0  0.0  4.0  12.0  \n",
       "castrja01   1.0  0.0  34  151.0  1.0  9.0  1.0  3.0  11.0  \n",
       "corpoca01   0.0  0.0  14   37.0  0.0  3.0  1.0  2.0   3.0  \n",
       "dominma01   0.0  1.0  29  125.0  2.0  5.0  2.0  7.0  23.0  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseball_14 = pd.read_csv('data/baseball14.csv', index_col='playerID')\n",
    "baseball_15 = pd.read_csv('data/baseball15.csv', index_col='playerID')\n",
    "baseball_16 = pd.read_csv('data/baseball16.csv', index_col='playerID')\n",
    "baseball_14.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['corpoca01', 'dominma01', 'fowlede01', 'grossro01', 'guzmaje01',\n",
       "       'hoeslj01', 'krausma01', 'preslal01', 'singljo02'],\n",
       "      dtype='object', name='playerID')"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseball_14.index.difference(baseball_15.index) # 找出不一样的索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "playerID\n",
       "altuvjo01    225\n",
       "cartech02    115\n",
       "castrja01    103\n",
       "corpoca01     40\n",
       "dominma01    121\n",
       "Name: H, dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hits_14 = baseball_14['H']\n",
    "hits_15 = baseball_15['H']\n",
    "hits_16 = baseball_16['H']\n",
    "hits_14.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "playerID\n",
       "altuvjo01    425.0\n",
       "cartech02    193.0\n",
       "castrja01    174.0\n",
       "congeha01      NaN\n",
       "corpoca01      NaN\n",
       "Name: H, dtype: float64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(hits_14 + hits_15).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "playerID\n",
       "altuvjo01    425.0\n",
       "cartech02    193.0\n",
       "castrja01    174.0\n",
       "congeha01     46.0\n",
       "corpoca01     40.0\n",
       "Name: H, dtype: float64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hits_14.add(hits_15, fill_value=0).head() # 出现空值填充指定的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "playerID\n",
       "altuvjo01    641.0\n",
       "bregmal01     53.0\n",
       "cartech02    193.0\n",
       "castrja01    243.0\n",
       "congeha01     46.0\n",
       "Name: H, dtype: float64"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hits_total = hits_14.add(hits_15, fill_value=0).add(hits_16, fill_value=0)\n",
    "hits_total.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hits_total.hasnans # 因为指定了fill_value，所以没有空值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    NaN\n",
       "b    3.0\n",
       "c    NaN\n",
       "d    1.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series(index=['a', 'b', 'c', 'd'], data=[np.nan, 3, np.nan, 1])\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a     NaN\n",
       "b     6.0\n",
       "c    10.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 = pd.Series(index=['a', 'b', 'c'], data=[np.nan, 6, 10])\n",
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a     NaN\n",
       "b     9.0\n",
       "c    15.0\n",
       "d     6.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.add(s1, fill_value=5) # a因为两边都是NaN，所以不动。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a     NaN\n",
       "b     9.0\n",
       "c    15.0\n",
       "d     6.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.add(s, fill_value=5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>G</th>\n",
       "      <th>AB</th>\n",
       "      <th>R</th>\n",
       "      <th>H</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>playerID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>altuvjo01</th>\n",
       "      <td>158</td>\n",
       "      <td>660</td>\n",
       "      <td>85</td>\n",
       "      <td>225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cartech02</th>\n",
       "      <td>145</td>\n",
       "      <td>507</td>\n",
       "      <td>68</td>\n",
       "      <td>115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>castrja01</th>\n",
       "      <td>126</td>\n",
       "      <td>465</td>\n",
       "      <td>43</td>\n",
       "      <td>103</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>corpoca01</th>\n",
       "      <td>55</td>\n",
       "      <td>170</td>\n",
       "      <td>22</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>dominma01</th>\n",
       "      <td>157</td>\n",
       "      <td>564</td>\n",
       "      <td>51</td>\n",
       "      <td>121</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             G   AB   R    H\n",
       "playerID                    \n",
       "altuvjo01  158  660  85  225\n",
       "cartech02  145  507  68  115\n",
       "castrja01  126  465  43  103\n",
       "corpoca01   55  170  22   40\n",
       "dominma01  157  564  51  121"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_14 = baseball_14[['G','AB', 'R', 'H']]\n",
    "df_14.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AB</th>\n",
       "      <th>R</th>\n",
       "      <th>H</th>\n",
       "      <th>HR</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>playerID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>altuvjo01</th>\n",
       "      <td>638</td>\n",
       "      <td>86</td>\n",
       "      <td>200</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cartech02</th>\n",
       "      <td>391</td>\n",
       "      <td>50</td>\n",
       "      <td>78</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>castrja01</th>\n",
       "      <td>337</td>\n",
       "      <td>38</td>\n",
       "      <td>71</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>congeha01</th>\n",
       "      <td>201</td>\n",
       "      <td>25</td>\n",
       "      <td>46</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>correca01</th>\n",
       "      <td>387</td>\n",
       "      <td>52</td>\n",
       "      <td>108</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            AB   R    H  HR\n",
       "playerID                   \n",
       "altuvjo01  638  86  200  15\n",
       "cartech02  391  50   78  24\n",
       "castrja01  337  38   71  11\n",
       "congeha01  201  25   46  11\n",
       "correca01  387  52  108  22"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_15 = baseball_15[['AB', 'R', 'H', 'HR']]\n",
    "df_15.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row0_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row0_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row1_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row1_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row2_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row2_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col4 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col4 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col4 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col4 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col4 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col4 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col4 {\n",
       "            background-color:  yellow;\n",
       "        }</style><table id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >AB</th>        <th class=\"col_heading level0 col1\" >G</th>        <th class=\"col_heading level0 col2\" >H</th>        <th class=\"col_heading level0 col3\" >HR</th>        <th class=\"col_heading level0 col4\" >R</th>    </tr>    <tr>        <th class=\"index_name level0\" >playerID</th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row0\" class=\"row_heading level0 row0\" >altuvjo01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row0_col0\" class=\"data row0 col0\" >1298.000000</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row0_col1\" class=\"data row0 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row0_col2\" class=\"data row0 col2\" >425.000000</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row0_col3\" class=\"data row0 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row0_col4\" class=\"data row0 col4\" >171.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row1\" class=\"row_heading level0 row1\" >cartech02</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row1_col0\" class=\"data row1 col0\" >898.000000</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row1_col1\" class=\"data row1 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row1_col2\" class=\"data row1 col2\" >193.000000</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row1_col3\" class=\"data row1 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row1_col4\" class=\"data row1 col4\" >118.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row2\" class=\"row_heading level0 row2\" >castrja01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row2_col0\" class=\"data row2 col0\" >802.000000</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row2_col1\" class=\"data row2 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row2_col2\" class=\"data row2 col2\" >174.000000</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row2_col3\" class=\"data row2 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row2_col4\" class=\"data row2 col4\" >81.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row3\" class=\"row_heading level0 row3\" >congeha01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col0\" class=\"data row3 col0\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col1\" class=\"data row3 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col2\" class=\"data row3 col2\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col3\" class=\"data row3 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row3_col4\" class=\"data row3 col4\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row4\" class=\"row_heading level0 row4\" >corpoca01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col0\" class=\"data row4 col0\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col1\" class=\"data row4 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col2\" class=\"data row4 col2\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col3\" class=\"data row4 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row4_col4\" class=\"data row4 col4\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row5\" class=\"row_heading level0 row5\" >correca01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col0\" class=\"data row5 col0\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col1\" class=\"data row5 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col2\" class=\"data row5 col2\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col3\" class=\"data row5 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row5_col4\" class=\"data row5 col4\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row6\" class=\"row_heading level0 row6\" >dominma01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col0\" class=\"data row6 col0\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col1\" class=\"data row6 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col2\" class=\"data row6 col2\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col3\" class=\"data row6 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row6_col4\" class=\"data row6 col4\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row7\" class=\"row_heading level0 row7\" >fowlede01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col0\" class=\"data row7 col0\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col1\" class=\"data row7 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col2\" class=\"data row7 col2\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col3\" class=\"data row7 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row7_col4\" class=\"data row7 col4\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row8\" class=\"row_heading level0 row8\" >gattiev01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col0\" class=\"data row8 col0\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col1\" class=\"data row8 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col2\" class=\"data row8 col2\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col3\" class=\"data row8 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row8_col4\" class=\"data row8 col4\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930level0_row9\" class=\"row_heading level0 row9\" >gomezca01</th>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col0\" class=\"data row9 col0\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col1\" class=\"data row9 col1\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col2\" class=\"data row9 col2\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col3\" class=\"data row9 col3\" >nan</td>\n",
       "                        <td id=\"T_f47aca64_b6bd_11eb_962b_548d5ad1d930row9_col4\" class=\"data row9 col4\" >nan</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0xf7c8d18>"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(df_14 + df_15).head(10).style.highlight_null('yellow') # 空值用黄色标记"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row3_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row4_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row5_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row6_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row7_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row8_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row9_col1 {\n",
       "            background-color:  yellow;\n",
       "        }</style><table id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >AB</th>        <th class=\"col_heading level0 col1\" >G</th>        <th class=\"col_heading level0 col2\" >H</th>        <th class=\"col_heading level0 col3\" >HR</th>        <th class=\"col_heading level0 col4\" >R</th>    </tr>    <tr>        <th class=\"index_name level0\" >playerID</th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row0\" class=\"row_heading level0 row0\" >altuvjo01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row0_col0\" class=\"data row0 col0\" >1298.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row0_col1\" class=\"data row0 col1\" >158.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row0_col2\" class=\"data row0 col2\" >425.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row0_col3\" class=\"data row0 col3\" >15.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row0_col4\" class=\"data row0 col4\" >171.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row1\" class=\"row_heading level0 row1\" >cartech02</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row1_col0\" class=\"data row1 col0\" >898.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row1_col1\" class=\"data row1 col1\" >145.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row1_col2\" class=\"data row1 col2\" >193.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row1_col3\" class=\"data row1 col3\" >24.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row1_col4\" class=\"data row1 col4\" >118.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row2\" class=\"row_heading level0 row2\" >castrja01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row2_col0\" class=\"data row2 col0\" >802.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row2_col1\" class=\"data row2 col1\" >126.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row2_col2\" class=\"data row2 col2\" >174.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row2_col3\" class=\"data row2 col3\" >11.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row2_col4\" class=\"data row2 col4\" >81.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row3\" class=\"row_heading level0 row3\" >congeha01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row3_col0\" class=\"data row3 col0\" >201.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row3_col1\" class=\"data row3 col1\" >nan</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row3_col2\" class=\"data row3 col2\" >46.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row3_col3\" class=\"data row3 col3\" >11.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row3_col4\" class=\"data row3 col4\" >25.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row4\" class=\"row_heading level0 row4\" >corpoca01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row4_col0\" class=\"data row4 col0\" >170.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row4_col1\" class=\"data row4 col1\" >55.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row4_col2\" class=\"data row4 col2\" >40.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row4_col3\" class=\"data row4 col3\" >nan</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row4_col4\" class=\"data row4 col4\" >22.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row5\" class=\"row_heading level0 row5\" >correca01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row5_col0\" class=\"data row5 col0\" >387.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row5_col1\" class=\"data row5 col1\" >nan</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row5_col2\" class=\"data row5 col2\" >108.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row5_col3\" class=\"data row5 col3\" >22.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row5_col4\" class=\"data row5 col4\" >52.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row6\" class=\"row_heading level0 row6\" >dominma01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row6_col0\" class=\"data row6 col0\" >564.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row6_col1\" class=\"data row6 col1\" >157.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row6_col2\" class=\"data row6 col2\" >121.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row6_col3\" class=\"data row6 col3\" >nan</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row6_col4\" class=\"data row6 col4\" >51.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row7\" class=\"row_heading level0 row7\" >fowlede01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row7_col0\" class=\"data row7 col0\" >434.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row7_col1\" class=\"data row7 col1\" >116.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row7_col2\" class=\"data row7 col2\" >120.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row7_col3\" class=\"data row7 col3\" >nan</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row7_col4\" class=\"data row7 col4\" >61.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row8\" class=\"row_heading level0 row8\" >gattiev01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row8_col0\" class=\"data row8 col0\" >566.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row8_col1\" class=\"data row8 col1\" >nan</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row8_col2\" class=\"data row8 col2\" >139.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row8_col3\" class=\"data row8 col3\" >27.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row8_col4\" class=\"data row8 col4\" >66.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930level0_row9\" class=\"row_heading level0 row9\" >gomezca01</th>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row9_col0\" class=\"data row9 col0\" >149.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row9_col1\" class=\"data row9 col1\" >nan</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row9_col2\" class=\"data row9 col2\" >36.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row9_col3\" class=\"data row9 col3\" >4.000000</td>\n",
       "                        <td id=\"T_f48aae96_b6bd_11eb_9ff5_548d5ad1d930row9_col4\" class=\"data row9 col4\" >19.000000</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0xf7c2e08>"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_14.add(df_15, fill_value=0).head(10).style.highlight_null('yellow') # 用add替换+，并指定fill_value，除非两边的值都是NaN。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 使用其它DataFrame添加列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "employee = pd.read_csv('data/employee.csv')\n",
    "dept_sal = employee[['DEPARTMENT', 'BASE_SALARY']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "dept_sal = dept_sal.sort_values(['DEPARTMENT', 'BASE_SALARY'],\n",
    "                                ascending=[True, False]) # 一个升序一个降序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DEPARTMENT</th>\n",
       "      <th>BASE_SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1494</th>\n",
       "      <td>Admn. &amp; Regulatory Affairs</td>\n",
       "      <td>140416.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>City Controller's Office</td>\n",
       "      <td>64251.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>236</th>\n",
       "      <td>City Council</td>\n",
       "      <td>100000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>647</th>\n",
       "      <td>Convention and Entertainment</td>\n",
       "      <td>38397.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1500</th>\n",
       "      <td>Dept of Neighborhoods (DON)</td>\n",
       "      <td>89221.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        DEPARTMENT  BASE_SALARY\n",
       "1494    Admn. & Regulatory Affairs     140416.0\n",
       "149       City Controller's Office      64251.0\n",
       "236                   City Council     100000.0\n",
       "647   Convention and Entertainment      38397.0\n",
       "1500   Dept of Neighborhoods (DON)      89221.0"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "max_dept_sal = dept_sal.drop_duplicates(subset='DEPARTMENT') # 删除重复的，默认保留第一个。\n",
    "max_dept_sal.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "max_dept_sal = max_dept_sal.set_index('DEPARTMENT')\n",
    "employee = employee.set_index('DEPARTMENT')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "employee['MAX_DEPT_SALARY'] = max_dept_sal['BASE_SALARY'] # 前面两个df都指定了相同的索引，所以可以根据索引去匹配值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.options.display.max_columns = 6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UNIQUE_ID</th>\n",
       "      <th>POSITION_TITLE</th>\n",
       "      <th>BASE_SALARY</th>\n",
       "      <th>...</th>\n",
       "      <th>HIRE_DATE</th>\n",
       "      <th>JOB_DATE</th>\n",
       "      <th>MAX_DEPT_SALARY</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DEPARTMENT</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Municipal Courts Department</th>\n",
       "      <td>0</td>\n",
       "      <td>ASSISTANT DIRECTOR (EX LVL)</td>\n",
       "      <td>121862.0</td>\n",
       "      <td>...</td>\n",
       "      <td>2006-06-12</td>\n",
       "      <td>2012-10-13</td>\n",
       "      <td>121862.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Library</th>\n",
       "      <td>1</td>\n",
       "      <td>LIBRARY ASSISTANT</td>\n",
       "      <td>26125.0</td>\n",
       "      <td>...</td>\n",
       "      <td>2000-07-19</td>\n",
       "      <td>2010-09-18</td>\n",
       "      <td>107763.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Houston Police Department-HPD</th>\n",
       "      <td>2</td>\n",
       "      <td>POLICE OFFICER</td>\n",
       "      <td>45279.0</td>\n",
       "      <td>...</td>\n",
       "      <td>2015-02-03</td>\n",
       "      <td>2015-02-03</td>\n",
       "      <td>199596.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Houston Fire Department (HFD)</th>\n",
       "      <td>3</td>\n",
       "      <td>ENGINEER/OPERATOR</td>\n",
       "      <td>63166.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1982-02-08</td>\n",
       "      <td>1991-05-25</td>\n",
       "      <td>210588.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>General Services Department</th>\n",
       "      <td>4</td>\n",
       "      <td>ELECTRICIAN</td>\n",
       "      <td>56347.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1989-06-19</td>\n",
       "      <td>1994-10-22</td>\n",
       "      <td>89194.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                               UNIQUE_ID               POSITION_TITLE  \\\n",
       "DEPARTMENT                                                              \n",
       "Municipal Courts Department            0  ASSISTANT DIRECTOR (EX LVL)   \n",
       "Library                                1            LIBRARY ASSISTANT   \n",
       "Houston Police Department-HPD          2               POLICE OFFICER   \n",
       "Houston Fire Department (HFD)          3            ENGINEER/OPERATOR   \n",
       "General Services Department            4                  ELECTRICIAN   \n",
       "\n",
       "                               BASE_SALARY  ...   HIRE_DATE    JOB_DATE  \\\n",
       "DEPARTMENT                                  ...                           \n",
       "Municipal Courts Department       121862.0  ...  2006-06-12  2012-10-13   \n",
       "Library                            26125.0  ...  2000-07-19  2010-09-18   \n",
       "Houston Police Department-HPD      45279.0  ...  2015-02-03  2015-02-03   \n",
       "Houston Fire Department (HFD)      63166.0  ...  1982-02-08  1991-05-25   \n",
       "General Services Department        56347.0  ...  1989-06-19  1994-10-22   \n",
       "\n",
       "                              MAX_DEPT_SALARY  \n",
       "DEPARTMENT                                     \n",
       "Municipal Courts Department          121862.0  \n",
       "Library                              107763.0  \n",
       "Houston Police Department-HPD        199596.0  \n",
       "Houston Fire Department (HFD)        210588.0  \n",
       "General Services Department           89194.0  \n",
       "\n",
       "[5 rows x 10 columns]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employee.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UNIQUE_ID</th>\n",
       "      <th>POSITION_TITLE</th>\n",
       "      <th>BASE_SALARY</th>\n",
       "      <th>...</th>\n",
       "      <th>HIRE_DATE</th>\n",
       "      <th>JOB_DATE</th>\n",
       "      <th>MAX_DEPT_SALARY</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DEPARTMENT</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>0 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [UNIQUE_ID, POSITION_TITLE, BASE_SALARY, RACE, EMPLOYMENT_TYPE, GENDER, EMPLOYMENT_STATUS, HIRE_DATE, JOB_DATE, MAX_DEPT_SALARY]\n",
       "Index: []\n",
       "\n",
       "[0 rows x 10 columns]"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employee.query('BASE_SALARY > MAX_DEPT_SALARY') # 肯定没有！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>BASE_SALARY</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DEPARTMENT</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Public Works &amp; Engineering-PWE</th>\n",
       "      <td>50586.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Houston Police Department-HPD</th>\n",
       "      <td>66614.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Houston Police Department-HPD</th>\n",
       "      <td>66614.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Housing and Community Devp.</th>\n",
       "      <td>78853.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Houston Police Department-HPD</th>\n",
       "      <td>66614.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Parks &amp; Recreation</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Public Works &amp; Engineering-PWE</th>\n",
       "      <td>37211.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Public Works &amp; Engineering-PWE</th>\n",
       "      <td>54683.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Human Resources Dept.</th>\n",
       "      <td>58474.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Health &amp; Human Services</th>\n",
       "      <td>47050.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                BASE_SALARY\n",
       "DEPARTMENT                                 \n",
       "Public Works & Engineering-PWE      50586.0\n",
       "Houston Police Department-HPD       66614.0\n",
       "Houston Police Department-HPD       66614.0\n",
       "Housing and Community Devp.         78853.0\n",
       "Houston Police Department-HPD       66614.0\n",
       "Parks & Recreation                      NaN\n",
       "Public Works & Engineering-PWE      37211.0\n",
       "Public Works & Engineering-PWE      54683.0\n",
       "Human Resources Dept.               58474.0\n",
       "Health & Human Services             47050.0"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.seed(1234)\n",
    "random_salary = dept_sal.sample(n=10).set_index('DEPARTMENT') # 随机采样10条数据\n",
    "random_salary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "cannot reindex from a duplicate axis",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-56-213f1e5b6c6f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0memployee\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'RANDOM_SALARY'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrandom_salary\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'BASE_SALARY'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;31m# random_salary存在重复索引，匹配的时候不知道该匹配那一条。\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__setitem__\u001b[1;34m(self, key, value)\u001b[0m\n\u001b[0;32m   2936\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2937\u001b[0m             \u001b[1;31m# set column\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2938\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_set_item\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2939\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2940\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m_setitem_slice\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m_set_item\u001b[1;34m(self, key, value)\u001b[0m\n\u001b[0;32m   2998\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2999\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_ensure_valid_index\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3000\u001b[1;33m         \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_sanitize_column\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3001\u001b[0m         \u001b[0mNDFrame\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_set_item\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3002\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m_sanitize_column\u001b[1;34m(self, key, value, broadcast)\u001b[0m\n\u001b[0;32m   3611\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3612\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mSeries\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3613\u001b[1;33m             \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mreindexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3614\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3615\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mDataFrame\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36mreindexer\u001b[1;34m(value)\u001b[0m\n\u001b[0;32m   3602\u001b[0m                     \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_unique\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3603\u001b[0m                         \u001b[1;31m# duplicate axis\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3604\u001b[1;33m                         \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3605\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3606\u001b[0m                     \u001b[1;31m# other\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36mreindexer\u001b[1;34m(value)\u001b[0m\n\u001b[0;32m   3597\u001b[0m                 \u001b[1;31m# GH 4107\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3598\u001b[0m                 \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3599\u001b[1;33m                     \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_values\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3600\u001b[0m                 \u001b[1;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3601\u001b[0m                     \u001b[1;31m# raised in MultiIndex.from_tuples, see test_insert_error_msmgs\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\series.py\u001b[0m in \u001b[0;36mreindex\u001b[1;34m(self, index, **kwargs)\u001b[0m\n\u001b[0;32m   4028\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0mAppender\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mgeneric\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mNDFrame\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreindex\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4029\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mreindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 4030\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0msuper\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   4031\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4032\u001b[0m     def drop(\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mreindex\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m   4541\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4542\u001b[0m         \u001b[1;31m# perform the reindex on the axes\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 4543\u001b[1;33m         return self._reindex_axes(\n\u001b[0m\u001b[0;32m   4544\u001b[0m             \u001b[0maxes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlimit\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfill_value\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4545\u001b[0m         ).__finalize__(self)\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36m_reindex_axes\u001b[1;34m(self, axes, level, limit, tolerance, method, fill_value, copy)\u001b[0m\n\u001b[0;32m   4561\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4562\u001b[0m             \u001b[0maxis\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_axis_number\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 4563\u001b[1;33m             obj = obj._reindex_with_indexers(\n\u001b[0m\u001b[0;32m   4564\u001b[0m                 \u001b[1;33m{\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mnew_index\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4565\u001b[0m                 \u001b[0mfill_value\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mfill_value\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36m_reindex_with_indexers\u001b[1;34m(self, reindexers, fill_value, copy, allow_dups)\u001b[0m\n\u001b[0;32m   4605\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4606\u001b[0m             \u001b[1;31m# TODO: speed up on homogeneous DataFrame objects\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 4607\u001b[1;33m             new_data = new_data.reindex_indexer(\n\u001b[0m\u001b[0;32m   4608\u001b[0m                 \u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4609\u001b[0m                 \u001b[0mindexer\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\internals\\managers.py\u001b[0m in \u001b[0;36mreindex_indexer\u001b[1;34m(self, new_axis, indexer, axis, fill_value, allow_dups, copy)\u001b[0m\n\u001b[0;32m   1249\u001b[0m         \u001b[1;31m# some axes don't allow reindexing with dups\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1250\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mallow_dups\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1251\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0maxes\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_can_reindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1252\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1253\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0maxis\u001b[0m \u001b[1;33m>=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndim\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\lin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36m_can_reindex\u001b[1;34m(self, indexer)\u001b[0m\n\u001b[0;32m   3096\u001b[0m         \u001b[1;31m# trying to reindex on an axis with duplicates\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3097\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_unique\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3098\u001b[1;33m             \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"cannot reindex from a duplicate axis\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3099\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3100\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mreindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtarget\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlimit\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: cannot reindex from a duplicate axis"
     ]
    }
   ],
   "source": [
    "employee['RANDOM_SALARY'] = random_salary['BASE_SALARY'] # random_salary存在重复索引，匹配的时候不知道该匹配那一条。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "employee['MAX_SALARY2'] = max_dept_sal['BASE_SALARY'].head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DEPARTMENT\n",
       "Municipal Courts Department     NaN\n",
       "Library                         NaN\n",
       "Houston Police Department-HPD   NaN\n",
       "Houston Fire Department (HFD)   NaN\n",
       "General Services Department     NaN\n",
       "                                 ..\n",
       "Houston Police Department-HPD   NaN\n",
       "Houston Fire Department (HFD)   NaN\n",
       "Houston Police Department-HPD   NaN\n",
       "Houston Police Department-HPD   NaN\n",
       "Houston Fire Department (HFD)   NaN\n",
       "Name: MAX_SALARY2, Length: 2000, dtype: float64"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employee['MAX_SALARY2']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "140416.0    29\n",
       "100000.0    11\n",
       "64251.0      5\n",
       "Name: MAX_SALARY2, dtype: int64"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employee.MAX_SALARY2.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9775"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employee.MAX_SALARY2.isnull().mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 高亮显示每列最大值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.options.display.max_rows = 8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CITY                   object\n",
       "STABBR                 object\n",
       "HBCU                  float64\n",
       "MENONLY               float64\n",
       "                       ...   \n",
       "PCTFLOAN              float64\n",
       "UG25ABV               float64\n",
       "MD_EARN_WNE_P10        object\n",
       "GRAD_DEBT_MDN_SUPP     object\n",
       "Length: 26, dtype: object"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')\n",
    "college.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'30300'"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.MD_EARN_WNE_P10.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'33888'"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.GRAD_DEBT_MDN_SUPP.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Sharon Regional Health System School of Nursing    PrivacySuppressed\n",
       "Northcoast Medical Training Academy                PrivacySuppressed\n",
       "Success Schools                                    PrivacySuppressed\n",
       "Louisiana Culinary Institute                       PrivacySuppressed\n",
       "Bais Medrash Toras Chesed                          PrivacySuppressed\n",
       "Name: MD_EARN_WNE_P10, dtype: object"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.MD_EARN_WNE_P10.sort_values(ascending=False).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MD_EARN_WNE_P10       float64\n",
       "GRAD_DEBT_MDN_SUPP    float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cols = ['MD_EARN_WNE_P10', 'GRAD_DEBT_MDN_SUPP']\n",
    "for col in cols:\n",
    "    college[col] = pd.to_numeric(college[col], errors='coerce') # 转数字，不能转就设置为NaN。\n",
    "\n",
    "college.dtypes.loc[cols]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>HBCU</th>\n",
       "      <th>MENONLY</th>\n",
       "      <th>WOMENONLY</th>\n",
       "      <th>...</th>\n",
       "      <th>UG25ABV</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.1049</td>\n",
       "      <td>30300.0</td>\n",
       "      <td>33888.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.2422</td>\n",
       "      <td>39700.0</td>\n",
       "      <td>21941.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.8540</td>\n",
       "      <td>40100.0</td>\n",
       "      <td>23370.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.2640</td>\n",
       "      <td>45500.0</td>\n",
       "      <td>24097.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Alabama State University</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.1270</td>\n",
       "      <td>26600.0</td>\n",
       "      <td>33118.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     HBCU  MENONLY  WOMENONLY  ...  UG25ABV  \\\n",
       "INSTNM                                                         ...            \n",
       "Alabama A & M University              1.0      0.0        0.0  ...   0.1049   \n",
       "University of Alabama at Birmingham   0.0      0.0        0.0  ...   0.2422   \n",
       "Amridge University                    0.0      0.0        0.0  ...   0.8540   \n",
       "University of Alabama in Huntsville   0.0      0.0        0.0  ...   0.2640   \n",
       "Alabama State University              1.0      0.0        0.0  ...   0.1270   \n",
       "\n",
       "                                     MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP  \n",
       "INSTNM                                                                    \n",
       "Alabama A & M University                     30300.0             33888.0  \n",
       "University of Alabama at Birmingham          39700.0             21941.5  \n",
       "Amridge University                           40100.0             23370.0  \n",
       "University of Alabama in Huntsville          45500.0             24097.0  \n",
       "Alabama State University                     26600.0             33118.5  \n",
       "\n",
       "[5 rows x 24 columns]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n = college.select_dtypes(include=[np.number]) # 只选择数值列\n",
    "college_n.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "HBCU          True\n",
       "MENONLY       True\n",
       "WOMENONLY     True\n",
       "RELAFFIL      True\n",
       "SATVRMID     False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "criteria = college_n.nunique() == 2 # 不相同值数量为2的列，NaN会忽略不统计。\n",
    "criteria.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0    7062\n",
       "1.0     102\n",
       "Name: HBCU, dtype: int64"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n['HBCU'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['HBCU', 'MENONLY', 'WOMENONLY', 'RELAFFIL', 'DISTANCEONLY', 'CURROPER']"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "binary_cols = college_n.columns[criteria].tolist()\n",
    "binary_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SATVRMID</th>\n",
       "      <th>SATMTMID</th>\n",
       "      <th>UGDS</th>\n",
       "      <th>...</th>\n",
       "      <th>UG25ABV</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>424.0</td>\n",
       "      <td>420.0</td>\n",
       "      <td>4206.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.1049</td>\n",
       "      <td>30300.0</td>\n",
       "      <td>33888.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>570.0</td>\n",
       "      <td>565.0</td>\n",
       "      <td>11383.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.2422</td>\n",
       "      <td>39700.0</td>\n",
       "      <td>21941.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>291.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.8540</td>\n",
       "      <td>40100.0</td>\n",
       "      <td>23370.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>595.0</td>\n",
       "      <td>590.0</td>\n",
       "      <td>5451.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.2640</td>\n",
       "      <td>45500.0</td>\n",
       "      <td>24097.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Alabama State University</th>\n",
       "      <td>425.0</td>\n",
       "      <td>430.0</td>\n",
       "      <td>4811.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.1270</td>\n",
       "      <td>26600.0</td>\n",
       "      <td>33118.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 18 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     SATVRMID  SATMTMID     UGDS  ...  \\\n",
       "INSTNM                                                            ...   \n",
       "Alabama A & M University                424.0     420.0   4206.0  ...   \n",
       "University of Alabama at Birmingham     570.0     565.0  11383.0  ...   \n",
       "Amridge University                        NaN       NaN    291.0  ...   \n",
       "University of Alabama in Huntsville     595.0     590.0   5451.0  ...   \n",
       "Alabama State University                425.0     430.0   4811.0  ...   \n",
       "\n",
       "                                     UG25ABV  MD_EARN_WNE_P10  \\\n",
       "INSTNM                                                          \n",
       "Alabama A & M University              0.1049          30300.0   \n",
       "University of Alabama at Birmingham   0.2422          39700.0   \n",
       "Amridge University                    0.8540          40100.0   \n",
       "University of Alabama in Huntsville   0.2640          45500.0   \n",
       "Alabama State University              0.1270          26600.0   \n",
       "\n",
       "                                     GRAD_DEBT_MDN_SUPP  \n",
       "INSTNM                                                   \n",
       "Alabama A & M University                        33888.0  \n",
       "University of Alabama at Birmingham             21941.5  \n",
       "Amridge University                              23370.0  \n",
       "University of Alabama in Huntsville             24097.0  \n",
       "Alabama State University                        33118.5  \n",
       "\n",
       "[5 rows x 18 columns]"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n2 = college_n.drop(labels=binary_cols, axis='columns') # 只有2个不同值的列去掉\n",
    "college_n2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "SATVRMID                      California Institute of Technology\n",
       "SATMTMID                      California Institute of Technology\n",
       "UGDS                               University of Phoenix-Arizona\n",
       "UGDS_WHITE                Mr Leon's School of Hair Design-Moscow\n",
       "                                         ...                    \n",
       "PCTFLOAN                                  ABC Beauty College Inc\n",
       "UG25ABV                           Dongguk University-Los Angeles\n",
       "MD_EARN_WNE_P10                     Medical College of Wisconsin\n",
       "GRAD_DEBT_MDN_SUPP    Southwest University of Visual Arts-Tucson\n",
       "Length: 18, dtype: object"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "max_cols = college_n2.idxmax() # 每列的最大值出现在哪个索引\n",
    "max_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(765.0, 765.0)"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n2['SATVRMID']['California Institute of Technology'], college_n2['SATVRMID'].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['California Institute of Technology',\n",
       "       'University of Phoenix-Arizona',\n",
       "       \"Mr Leon's School of Hair Design-Moscow\",\n",
       "       'Velvatex College of Beauty Culture',\n",
       "       'Thunderbird School of Global Management'], dtype=object)"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "unique_max_cols = max_cols.unique()\n",
    "unique_max_cols[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col2 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col3 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col4 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col5 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col12 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col6 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col7 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col8 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col9 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col10 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col11 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col13 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col14 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col14 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col15 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col16 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col17 {\n",
       "            background-color:  yellow;\n",
       "        }</style><table id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >SATVRMID</th>        <th class=\"col_heading level0 col1\" >SATMTMID</th>        <th class=\"col_heading level0 col2\" >UGDS</th>        <th class=\"col_heading level0 col3\" >UGDS_WHITE</th>        <th class=\"col_heading level0 col4\" >UGDS_BLACK</th>        <th class=\"col_heading level0 col5\" >UGDS_HISP</th>        <th class=\"col_heading level0 col6\" >UGDS_ASIAN</th>        <th class=\"col_heading level0 col7\" >UGDS_AIAN</th>        <th class=\"col_heading level0 col8\" >UGDS_NHPI</th>        <th class=\"col_heading level0 col9\" >UGDS_2MOR</th>        <th class=\"col_heading level0 col10\" >UGDS_NRA</th>        <th class=\"col_heading level0 col11\" >UGDS_UNKN</th>        <th class=\"col_heading level0 col12\" >PPTUG_EF</th>        <th class=\"col_heading level0 col13\" >PCTPELL</th>        <th class=\"col_heading level0 col14\" >PCTFLOAN</th>        <th class=\"col_heading level0 col15\" >UG25ABV</th>        <th class=\"col_heading level0 col16\" >MD_EARN_WNE_P10</th>        <th class=\"col_heading level0 col17\" >GRAD_DEBT_MDN_SUPP</th>    </tr>    <tr>        <th class=\"index_name level0\" >INSTNM</th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row0\" class=\"row_heading level0 row0\" >California Institute of Technology</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col0\" class=\"data row0 col0\" >765.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col1\" class=\"data row0 col1\" >785.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col2\" class=\"data row0 col2\" >983.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col3\" class=\"data row0 col3\" >0.278700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col4\" class=\"data row0 col4\" >0.015300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col5\" class=\"data row0 col5\" >0.122100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col6\" class=\"data row0 col6\" >0.438500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col7\" class=\"data row0 col7\" >0.001000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col8\" class=\"data row0 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col9\" class=\"data row0 col9\" >0.057000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col10\" class=\"data row0 col10\" >0.087500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col11\" class=\"data row0 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col12\" class=\"data row0 col12\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col13\" class=\"data row0 col13\" >0.112600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col14\" class=\"data row0 col14\" >0.230300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col15\" class=\"data row0 col15\" >0.008200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col16\" class=\"data row0 col16\" >77800.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row0_col17\" class=\"data row0 col17\" >11812.500000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row1\" class=\"row_heading level0 row1\" >University of Phoenix-Arizona</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col0\" class=\"data row1 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col1\" class=\"data row1 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col2\" class=\"data row1 col2\" >151558.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col3\" class=\"data row1 col3\" >0.309800</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col4\" class=\"data row1 col4\" >0.155500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col5\" class=\"data row1 col5\" >0.076000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col6\" class=\"data row1 col6\" >0.008200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col7\" class=\"data row1 col7\" >0.004200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col8\" class=\"data row1 col8\" >0.005000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col9\" class=\"data row1 col9\" >0.113100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col10\" class=\"data row1 col10\" >0.013100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col11\" class=\"data row1 col11\" >0.315200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col12\" class=\"data row1 col12\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col13\" class=\"data row1 col13\" >0.600900</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col14\" class=\"data row1 col14\" >0.592000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col15\" class=\"data row1 col15\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col16\" class=\"data row1 col16\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row1_col17\" class=\"data row1 col17\" >33000.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row2\" class=\"row_heading level0 row2\" >Mr Leon's School of Hair Design-Moscow</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col0\" class=\"data row2 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col1\" class=\"data row2 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col2\" class=\"data row2 col2\" >16.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col3\" class=\"data row2 col3\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col4\" class=\"data row2 col4\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col5\" class=\"data row2 col5\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col6\" class=\"data row2 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col7\" class=\"data row2 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col8\" class=\"data row2 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col9\" class=\"data row2 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col10\" class=\"data row2 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col11\" class=\"data row2 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col12\" class=\"data row2 col12\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col13\" class=\"data row2 col13\" >0.625000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col14\" class=\"data row2 col14\" >0.625000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col15\" class=\"data row2 col15\" >0.200000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col16\" class=\"data row2 col16\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row2_col17\" class=\"data row2 col17\" >15710.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row3\" class=\"row_heading level0 row3\" >Velvatex College of Beauty Culture</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col0\" class=\"data row3 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col1\" class=\"data row3 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col2\" class=\"data row3 col2\" >25.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col3\" class=\"data row3 col3\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col4\" class=\"data row3 col4\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col5\" class=\"data row3 col5\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col6\" class=\"data row3 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col7\" class=\"data row3 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col8\" class=\"data row3 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col9\" class=\"data row3 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col10\" class=\"data row3 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col11\" class=\"data row3 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col12\" class=\"data row3 col12\" >0.200000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col13\" class=\"data row3 col13\" >0.769200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col14\" class=\"data row3 col14\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col15\" class=\"data row3 col15\" >0.520000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col16\" class=\"data row3 col16\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row3_col17\" class=\"data row3 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row4\" class=\"row_heading level0 row4\" >Thunderbird School of Global Management</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col0\" class=\"data row4 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col1\" class=\"data row4 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col2\" class=\"data row4 col2\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col3\" class=\"data row4 col3\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col4\" class=\"data row4 col4\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col5\" class=\"data row4 col5\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col6\" class=\"data row4 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col7\" class=\"data row4 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col8\" class=\"data row4 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col9\" class=\"data row4 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col10\" class=\"data row4 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col11\" class=\"data row4 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col12\" class=\"data row4 col12\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col13\" class=\"data row4 col13\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col14\" class=\"data row4 col14\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col15\" class=\"data row4 col15\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col16\" class=\"data row4 col16\" >118900.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row4_col17\" class=\"data row4 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row5\" class=\"row_heading level0 row5\" >Cosmopolitan Beauty and Tech School</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col0\" class=\"data row5 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col1\" class=\"data row5 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col2\" class=\"data row5 col2\" >110.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col3\" class=\"data row5 col3\" >0.009100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col4\" class=\"data row5 col4\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col5\" class=\"data row5 col5\" >0.018200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col6\" class=\"data row5 col6\" >0.972700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col7\" class=\"data row5 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col8\" class=\"data row5 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col9\" class=\"data row5 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col10\" class=\"data row5 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col11\" class=\"data row5 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col12\" class=\"data row5 col12\" >0.318200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col13\" class=\"data row5 col13\" >0.776100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col14\" class=\"data row5 col14\" >0.124400</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col15\" class=\"data row5 col15\" >0.954500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col16\" class=\"data row5 col16\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row5_col17\" class=\"data row5 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row6\" class=\"row_heading level0 row6\" >Haskell Indian Nations University</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col0\" class=\"data row6 col0\" >430.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col1\" class=\"data row6 col1\" >440.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col2\" class=\"data row6 col2\" >805.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col3\" class=\"data row6 col3\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col4\" class=\"data row6 col4\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col5\" class=\"data row6 col5\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col6\" class=\"data row6 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col7\" class=\"data row6 col7\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col8\" class=\"data row6 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col9\" class=\"data row6 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col10\" class=\"data row6 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col11\" class=\"data row6 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col12\" class=\"data row6 col12\" >0.022400</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col13\" class=\"data row6 col13\" >0.839600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col14\" class=\"data row6 col14\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col15\" class=\"data row6 col15\" >0.208900</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col16\" class=\"data row6 col16\" >22800.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row6_col17\" class=\"data row6 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row7\" class=\"row_heading level0 row7\" >Palau Community College</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col0\" class=\"data row7 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col1\" class=\"data row7 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col2\" class=\"data row7 col2\" >602.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col3\" class=\"data row7 col3\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col4\" class=\"data row7 col4\" >0.001700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col5\" class=\"data row7 col5\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col6\" class=\"data row7 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col7\" class=\"data row7 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col8\" class=\"data row7 col8\" >0.998300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col9\" class=\"data row7 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col10\" class=\"data row7 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col11\" class=\"data row7 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col12\" class=\"data row7 col12\" >0.388700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col13\" class=\"data row7 col13\" >0.856000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col14\" class=\"data row7 col14\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col15\" class=\"data row7 col15\" >0.261600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col16\" class=\"data row7 col16\" >24700.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row7_col17\" class=\"data row7 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row8\" class=\"row_heading level0 row8\" >LIU Brentwood</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col0\" class=\"data row8 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col1\" class=\"data row8 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col2\" class=\"data row8 col2\" >15.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col3\" class=\"data row8 col3\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col4\" class=\"data row8 col4\" >0.133300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col5\" class=\"data row8 col5\" >0.266700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col6\" class=\"data row8 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col7\" class=\"data row8 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col8\" class=\"data row8 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col9\" class=\"data row8 col9\" >0.533300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col10\" class=\"data row8 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col11\" class=\"data row8 col11\" >0.066700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col12\" class=\"data row8 col12\" >0.400000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col13\" class=\"data row8 col13\" >0.565200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col14\" class=\"data row8 col14\" >0.782600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col15\" class=\"data row8 col15\" >0.782600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col16\" class=\"data row8 col16\" >44600.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row8_col17\" class=\"data row8 col17\" >25499.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row9\" class=\"row_heading level0 row9\" >California University of Management and Sciences</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col0\" class=\"data row9 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col1\" class=\"data row9 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col2\" class=\"data row9 col2\" >98.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col3\" class=\"data row9 col3\" >0.010200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col4\" class=\"data row9 col4\" >0.020400</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col5\" class=\"data row9 col5\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col6\" class=\"data row9 col6\" >0.040800</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col7\" class=\"data row9 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col8\" class=\"data row9 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col9\" class=\"data row9 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col10\" class=\"data row9 col10\" >0.928600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col11\" class=\"data row9 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col12\" class=\"data row9 col12\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col13\" class=\"data row9 col13\" >0.092600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col14\" class=\"data row9 col14\" >0.055600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col15\" class=\"data row9 col15\" >0.685200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col16\" class=\"data row9 col16\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row9_col17\" class=\"data row9 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row10\" class=\"row_heading level0 row10\" >Le Cordon Bleu College of Culinary Arts-San Francisco</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col0\" class=\"data row10 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col1\" class=\"data row10 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col2\" class=\"data row10 col2\" >442.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col3\" class=\"data row10 col3\" >0.031700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col4\" class=\"data row10 col4\" >0.009000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col5\" class=\"data row10 col5\" >0.011300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col6\" class=\"data row10 col6\" >0.027100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col7\" class=\"data row10 col7\" >0.004500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col8\" class=\"data row10 col8\" >0.002300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col9\" class=\"data row10 col9\" >0.011300</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col10\" class=\"data row10 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col11\" class=\"data row10 col11\" >0.902700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col12\" class=\"data row10 col12\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col13\" class=\"data row10 col13\" >0.372200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col14\" class=\"data row10 col14\" >0.535800</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col15\" class=\"data row10 col15\" >0.544000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col16\" class=\"data row10 col16\" >34000.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row10_col17\" class=\"data row10 col17\" >12931.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row11\" class=\"row_heading level0 row11\" >MTI Business College Inc</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col0\" class=\"data row11 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col1\" class=\"data row11 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col2\" class=\"data row11 col2\" >146.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col3\" class=\"data row11 col3\" >0.239700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col4\" class=\"data row11 col4\" >0.513700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col5\" class=\"data row11 col5\" >0.143800</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col6\" class=\"data row11 col6\" >0.047900</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col7\" class=\"data row11 col7\" >0.034200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col8\" class=\"data row11 col8\" >0.020500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col9\" class=\"data row11 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col10\" class=\"data row11 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col11\" class=\"data row11 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col12\" class=\"data row11 col12\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col13\" class=\"data row11 col13\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col14\" class=\"data row11 col14\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col15\" class=\"data row11 col15\" >0.398600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col16\" class=\"data row11 col16\" >23000.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row11_col17\" class=\"data row11 col17\" >9500.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row12\" class=\"row_heading level0 row12\" >ABC Beauty College Inc</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col0\" class=\"data row12 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col1\" class=\"data row12 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col2\" class=\"data row12 col2\" >38.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col3\" class=\"data row12 col3\" >0.289500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col4\" class=\"data row12 col4\" >0.657900</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col5\" class=\"data row12 col5\" >0.052600</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col6\" class=\"data row12 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col7\" class=\"data row12 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col8\" class=\"data row12 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col9\" class=\"data row12 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col10\" class=\"data row12 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col11\" class=\"data row12 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col12\" class=\"data row12 col12\" >0.210500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col13\" class=\"data row12 col13\" >0.981500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col14\" class=\"data row12 col14\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col15\" class=\"data row12 col15\" >0.468800</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col16\" class=\"data row12 col16\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row12_col17\" class=\"data row12 col17\" >16500.000000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row13\" class=\"row_heading level0 row13\" >Dongguk University-Los Angeles</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col0\" class=\"data row13 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col1\" class=\"data row13 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col2\" class=\"data row13 col2\" >20.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col3\" class=\"data row13 col3\" >0.350000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col4\" class=\"data row13 col4\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col5\" class=\"data row13 col5\" >0.150000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col6\" class=\"data row13 col6\" >0.500000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col7\" class=\"data row13 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col8\" class=\"data row13 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col9\" class=\"data row13 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col10\" class=\"data row13 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col11\" class=\"data row13 col11\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col12\" class=\"data row13 col12\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col13\" class=\"data row13 col13\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col14\" class=\"data row13 col14\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col15\" class=\"data row13 col15\" >1.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col16\" class=\"data row13 col16\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row13_col17\" class=\"data row13 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row14\" class=\"row_heading level0 row14\" >Medical College of Wisconsin</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col0\" class=\"data row14 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col1\" class=\"data row14 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col2\" class=\"data row14 col2\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col3\" class=\"data row14 col3\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col4\" class=\"data row14 col4\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col5\" class=\"data row14 col5\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col6\" class=\"data row14 col6\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col7\" class=\"data row14 col7\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col8\" class=\"data row14 col8\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col9\" class=\"data row14 col9\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col10\" class=\"data row14 col10\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col11\" class=\"data row14 col11\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col12\" class=\"data row14 col12\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col13\" class=\"data row14 col13\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col14\" class=\"data row14 col14\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col15\" class=\"data row14 col15\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col16\" class=\"data row14 col16\" >233100.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row14_col17\" class=\"data row14 col17\" >nan</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930level0_row15\" class=\"row_heading level0 row15\" >Southwest University of Visual Arts-Tucson</th>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col0\" class=\"data row15 col0\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col1\" class=\"data row15 col1\" >nan</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col2\" class=\"data row15 col2\" >161.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col3\" class=\"data row15 col3\" >0.453400</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col4\" class=\"data row15 col4\" >0.043500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col5\" class=\"data row15 col5\" >0.316800</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col6\" class=\"data row15 col6\" >0.006200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col7\" class=\"data row15 col7\" >0.031100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col8\" class=\"data row15 col8\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col9\" class=\"data row15 col9\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col10\" class=\"data row15 col10\" >0.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col11\" class=\"data row15 col11\" >0.149100</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col12\" class=\"data row15 col12\" >0.279500</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col13\" class=\"data row15 col13\" >0.446900</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col14\" class=\"data row15 col14\" >0.429200</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col15\" class=\"data row15 col15\" >0.865700</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col16\" class=\"data row15 col16\" >27200.000000</td>\n",
       "                        <td id=\"T_fa0481e2_b6bd_11eb_8a31_548d5ad1d930row15_col17\" class=\"data row15 col17\" >49750.000000</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x123b31a8>"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n2.loc[unique_max_cols].style.highlight_max() # 用Series记录行列关系"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col1 {\n",
       "            background-color:  yellow;\n",
       "        }</style><table id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >UGDS_WHITE</th>        <th class=\"col_heading level0 col1\" >UGDS_BLACK</th>        <th class=\"col_heading level0 col2\" >UGDS_HISP</th>        <th class=\"col_heading level0 col3\" >UGDS_ASIAN</th>        <th class=\"col_heading level0 col4\" >UGDS_AIAN</th>        <th class=\"col_heading level0 col5\" >UGDS_NHPI</th>        <th class=\"col_heading level0 col6\" >UGDS_2MOR</th>        <th class=\"col_heading level0 col7\" >UGDS_NRA</th>        <th class=\"col_heading level0 col8\" >UGDS_UNKN</th>    </tr>    <tr>        <th class=\"index_name level0\" >INSTNM</th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930level0_row0\" class=\"row_heading level0 row0\" >Alabama A & M University</th>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col0\" class=\"data row0 col0\" >0.033300</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col1\" class=\"data row0 col1\" >0.935300</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col2\" class=\"data row0 col2\" >0.005500</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col3\" class=\"data row0 col3\" >0.001900</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col4\" class=\"data row0 col4\" >0.002400</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col5\" class=\"data row0 col5\" >0.001900</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col6\" class=\"data row0 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col7\" class=\"data row0 col7\" >0.005900</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row0_col8\" class=\"data row0 col8\" >0.013800</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930level0_row1\" class=\"row_heading level0 row1\" >University of Alabama at Birmingham</th>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col0\" class=\"data row1 col0\" >0.592200</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col1\" class=\"data row1 col1\" >0.260000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col2\" class=\"data row1 col2\" >0.028300</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col3\" class=\"data row1 col3\" >0.051800</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col4\" class=\"data row1 col4\" >0.002200</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col5\" class=\"data row1 col5\" >0.000700</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col6\" class=\"data row1 col6\" >0.036800</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col7\" class=\"data row1 col7\" >0.017900</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row1_col8\" class=\"data row1 col8\" >0.010000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930level0_row2\" class=\"row_heading level0 row2\" >Amridge University</th>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col0\" class=\"data row2 col0\" >0.299000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col1\" class=\"data row2 col1\" >0.419200</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col2\" class=\"data row2 col2\" >0.006900</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col3\" class=\"data row2 col3\" >0.003400</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col4\" class=\"data row2 col4\" >0.000000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col5\" class=\"data row2 col5\" >0.000000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col6\" class=\"data row2 col6\" >0.000000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col7\" class=\"data row2 col7\" >0.000000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row2_col8\" class=\"data row2 col8\" >0.271500</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930level0_row3\" class=\"row_heading level0 row3\" >University of Alabama in Huntsville</th>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col0\" class=\"data row3 col0\" >0.698800</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col1\" class=\"data row3 col1\" >0.125500</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col2\" class=\"data row3 col2\" >0.038200</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col3\" class=\"data row3 col3\" >0.037600</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col4\" class=\"data row3 col4\" >0.014300</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col5\" class=\"data row3 col5\" >0.000200</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col6\" class=\"data row3 col6\" >0.017200</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col7\" class=\"data row3 col7\" >0.033200</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row3_col8\" class=\"data row3 col8\" >0.035000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930level0_row4\" class=\"row_heading level0 row4\" >Alabama State University</th>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col0\" class=\"data row4 col0\" >0.015800</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col1\" class=\"data row4 col1\" >0.920800</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col2\" class=\"data row4 col2\" >0.012100</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col3\" class=\"data row4 col3\" >0.001900</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col4\" class=\"data row4 col4\" >0.001000</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col5\" class=\"data row4 col5\" >0.000600</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col6\" class=\"data row4 col6\" >0.009800</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col7\" class=\"data row4 col7\" >0.024300</td>\n",
       "                        <td id=\"T_fa209dfd_b6bd_11eb_a980_548d5ad1d930row4_col8\" class=\"data row4 col8\" >0.013700</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x1243b058>"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')\n",
    "college_ugds = college.filter(like='UGDS_').head()\n",
    "college_ugds.style.highlight_max(axis='columns')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 使用方法链复制idmax"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')\n",
    "\n",
    "cols = ['MD_EARN_WNE_P10', 'GRAD_DEBT_MDN_SUPP']\n",
    "for col in cols:\n",
    "    college[col] = pd.to_numeric(college[col], errors='coerce')\n",
    "\n",
    "college_n = college.select_dtypes(include=[np.number])\n",
    "criteria = college_n.nunique() == 2\n",
    "binary_cols = college_n.columns[criteria].tolist()\n",
    "college_n = college_n.drop(labels=binary_cols, axis='columns')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "SATVRMID         765.0\n",
       "SATMTMID         785.0\n",
       "UGDS          151558.0\n",
       "UGDS_WHITE         1.0\n",
       "UGDS_BLACK         1.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n.max().head() # 每列的最大值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SATVRMID</th>\n",
       "      <th>SATMTMID</th>\n",
       "      <th>UGDS</th>\n",
       "      <th>...</th>\n",
       "      <th>UG25ABV</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Alabama State University</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 18 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     SATVRMID  SATMTMID   UGDS  ...  UG25ABV  \\\n",
       "INSTNM                                                          ...            \n",
       "Alabama A & M University                False     False  False  ...    False   \n",
       "University of Alabama at Birmingham     False     False  False  ...    False   \n",
       "Amridge University                      False     False  False  ...    False   \n",
       "University of Alabama in Huntsville     False     False  False  ...    False   \n",
       "Alabama State University                False     False  False  ...    False   \n",
       "\n",
       "                                     MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP  \n",
       "INSTNM                                                                    \n",
       "Alabama A & M University                       False               False  \n",
       "University of Alabama at Birmingham            False               False  \n",
       "Amridge University                             False               False  \n",
       "University of Alabama in Huntsville            False               False  \n",
       "Alabama State University                       False               False  \n",
       "\n",
       "[5 rows x 18 columns]"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n.eq(college_n.max()).head() # 每个元素与对应列的最大值比较"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University               False\n",
       "University of Alabama at Birmingham    False\n",
       "Amridge University                     False\n",
       "University of Alabama in Huntsville    False\n",
       "Alabama State University               False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "has_row_max = college_n.eq(college_n.max()).any(axis='columns') # 列的方向即从左到右，只要有一个值与所在列的最大值相等就是True。\n",
    "has_row_max.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7535, 18)"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "401"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "has_row_max.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.options.display.max_rows=6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SATVRMID</th>\n",
       "      <th>SATMTMID</th>\n",
       "      <th>UGDS</th>\n",
       "      <th>...</th>\n",
       "      <th>UG25ABV</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>National Personal Training Institute of Cleveland</th>\n",
       "      <td>7307</td>\n",
       "      <td>7307</td>\n",
       "      <td>417</td>\n",
       "      <td>...</td>\n",
       "      <td>36207</td>\n",
       "      <td>3447</td>\n",
       "      <td>10270</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bay Area Medical Academy - San Jose Satellite Location</th>\n",
       "      <td>7308</td>\n",
       "      <td>7308</td>\n",
       "      <td>418</td>\n",
       "      <td>...</td>\n",
       "      <td>36219</td>\n",
       "      <td>3448</td>\n",
       "      <td>10272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Excel Learning Center-San Antonio South</th>\n",
       "      <td>7309</td>\n",
       "      <td>7309</td>\n",
       "      <td>419</td>\n",
       "      <td>...</td>\n",
       "      <td>36231</td>\n",
       "      <td>3449</td>\n",
       "      <td>10274</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>7535 rows × 18 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    SATVRMID  SATMTMID  UGDS  \\\n",
       "INSTNM                                                                         \n",
       "Alabama A & M University                                   0         0     0   \n",
       "University of Alabama at Birmingham                        0         0     0   \n",
       "Amridge University                                         0         0     0   \n",
       "...                                                      ...       ...   ...   \n",
       "National Personal Training Institute of Cleveland       7307      7307   417   \n",
       "Bay Area Medical Academy - San Jose Satellite L...      7308      7308   418   \n",
       "Excel Learning Center-San Antonio South                 7309      7309   419   \n",
       "\n",
       "                                                    ...  UG25ABV  \\\n",
       "INSTNM                                              ...            \n",
       "Alabama A & M University                            ...        0   \n",
       "University of Alabama at Birmingham                 ...        0   \n",
       "Amridge University                                  ...        0   \n",
       "...                                                 ...      ...   \n",
       "National Personal Training Institute of Cleveland   ...    36207   \n",
       "Bay Area Medical Academy - San Jose Satellite L...  ...    36219   \n",
       "Excel Learning Center-San Antonio South             ...    36231   \n",
       "\n",
       "                                                    MD_EARN_WNE_P10  \\\n",
       "INSTNM                                                                \n",
       "Alabama A & M University                                          0   \n",
       "University of Alabama at Birmingham                               0   \n",
       "Amridge University                                                0   \n",
       "...                                                             ...   \n",
       "National Personal Training Institute of Cleveland              3447   \n",
       "Bay Area Medical Academy - San Jose Satellite L...             3448   \n",
       "Excel Learning Center-San Antonio South                        3449   \n",
       "\n",
       "                                                    GRAD_DEBT_MDN_SUPP  \n",
       "INSTNM                                                                  \n",
       "Alabama A & M University                                             0  \n",
       "University of Alabama at Birmingham                                  0  \n",
       "Amridge University                                                   0  \n",
       "...                                                                ...  \n",
       "National Personal Training Institute of Cleveland                10270  \n",
       "Bay Area Medical Academy - San Jose Satellite L...               10272  \n",
       "Excel Learning Center-San Antonio South                          10274  \n",
       "\n",
       "[7535 rows x 18 columns]"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_n.eq(college_n.max()).cumsum().cumsum() # 如果相等设置为True，然后累加再累加。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University               False\n",
       "University of Alabama at Birmingham    False\n",
       "Amridge University                     False\n",
       "University of Alabama in Huntsville    False\n",
       "Alabama State University               False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "has_row_max2 = college_n.eq(college_n.max())\\\n",
    "                        .cumsum()\\\n",
    "                        .cumsum()\\\n",
    "                        .eq(1)\\\n",
    "                        .any(axis='columns') # TODO cumsum两遍还是要理解一下。\n",
    "has_row_max2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "has_row_max2.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Thunderbird School of Global Management',\n",
       "       'Southwest University of Visual Arts-Tucson', 'ABC Beauty College Inc',\n",
       "       'Velvatex College of Beauty Culture',\n",
       "       'California Institute of Technology',\n",
       "       'Le Cordon Bleu College of Culinary Arts-San Francisco',\n",
       "       'MTI Business College Inc', 'Dongguk University-Los Angeles',\n",
       "       'Mr Leon's School of Hair Design-Moscow',\n",
       "       'Haskell Indian Nations University', 'LIU Brentwood',\n",
       "       'Medical College of Wisconsin', 'Palau Community College',\n",
       "       'California University of Management and Sciences',\n",
       "       'Cosmopolitan Beauty and Tech School', 'University of Phoenix-Arizona'],\n",
       "      dtype='object', name='INSTNM')"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "idxmax_cols = has_row_max2[has_row_max2].index\n",
    "idxmax_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set(college_n.idxmax().unique()) == set(idxmax_cols)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.21 ms ± 55.3 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit college_n.idxmax().values # 看性能还是老老实实用idmax"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5.98 ms ± 388 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit college_n.eq(college_n.max())\\\n",
    "                              .cumsum()\\\n",
    "                              .cumsum()\\\n",
    "                              .eq(1)\\\n",
    "                              .any(axis='columns')\\\n",
    "                              [lambda x: x].index"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 寻找出现最多的最大值（哪一列在行上最大值的次数最多）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.options.display.max_rows= 40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UGDS_WHITE</th>\n",
       "      <th>UGDS_BLACK</th>\n",
       "      <th>UGDS_HISP</th>\n",
       "      <th>...</th>\n",
       "      <th>UGDS_2MOR</th>\n",
       "      <th>UGDS_NRA</th>\n",
       "      <th>UGDS_UNKN</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>0.0333</td>\n",
       "      <td>0.9353</td>\n",
       "      <td>0.0055</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0059</td>\n",
       "      <td>0.0138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>0.5922</td>\n",
       "      <td>0.2600</td>\n",
       "      <td>0.0283</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0368</td>\n",
       "      <td>0.0179</td>\n",
       "      <td>0.0100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>0.2990</td>\n",
       "      <td>0.4192</td>\n",
       "      <td>0.0069</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.2715</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>0.6988</td>\n",
       "      <td>0.1255</td>\n",
       "      <td>0.0382</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0172</td>\n",
       "      <td>0.0332</td>\n",
       "      <td>0.0350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Alabama State University</th>\n",
       "      <td>0.0158</td>\n",
       "      <td>0.9208</td>\n",
       "      <td>0.0121</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0098</td>\n",
       "      <td>0.0243</td>\n",
       "      <td>0.0137</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     UGDS_WHITE  UGDS_BLACK  UGDS_HISP  ...  \\\n",
       "INSTNM                                                                  ...   \n",
       "Alabama A & M University                 0.0333      0.9353     0.0055  ...   \n",
       "University of Alabama at Birmingham      0.5922      0.2600     0.0283  ...   \n",
       "Amridge University                       0.2990      0.4192     0.0069  ...   \n",
       "University of Alabama in Huntsville      0.6988      0.1255     0.0382  ...   \n",
       "Alabama State University                 0.0158      0.9208     0.0121  ...   \n",
       "\n",
       "                                     UGDS_2MOR  UGDS_NRA  UGDS_UNKN  \n",
       "INSTNM                                                               \n",
       "Alabama A & M University                0.0000    0.0059     0.0138  \n",
       "University of Alabama at Birmingham     0.0368    0.0179     0.0100  \n",
       "Amridge University                      0.0000    0.0000     0.2715  \n",
       "University of Alabama in Huntsville     0.0172    0.0332     0.0350  \n",
       "Alabama State University                0.0098    0.0243     0.0137  \n",
       "\n",
       "[5 rows x 9 columns]"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')\n",
    "college_ugds = college.filter(like='UGDS_')\n",
    "college_ugds.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University               UGDS_BLACK\n",
       "University of Alabama at Birmingham    UGDS_WHITE\n",
       "Amridge University                     UGDS_BLACK\n",
       "University of Alabama in Huntsville    UGDS_WHITE\n",
       "Alabama State University               UGDS_BLACK\n",
       "dtype: object"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "highest_percentage_race = college_ugds.idxmax(axis='columns') # 每行最大值对应的列\n",
    "highest_percentage_race.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "UGDS_WHITE    0.670352\n",
       "UGDS_BLACK    0.151586\n",
       "UGDS_HISP     0.129473\n",
       "UGDS_UNKN     0.023422\n",
       "UGDS_ASIAN    0.012074\n",
       "UGDS_AIAN     0.006110\n",
       "UGDS_NRA      0.004073\n",
       "UGDS_NHPI     0.001746\n",
       "UGDS_2MOR     0.001164\n",
       "dtype: float64"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "highest_percentage_race.value_counts(normalize=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                                 UGDS_WHITE\n",
       "Amridge University                                       UGDS_WHITE\n",
       "Alabama State University                                   UGDS_NRA\n",
       "Concordia College Alabama                                  UGDS_NRA\n",
       "South University-Montgomery                              UGDS_WHITE\n",
       "                                                            ...    \n",
       "New Horizons Medical Institute-Winder                    UGDS_WHITE\n",
       "SAE Institute of Technology-Chicago                      UGDS_WHITE\n",
       "Fayette Beauty Academy-Ritz Beauty Academy               UGDS_WHITE\n",
       "National American University-Houston                     UGDS_WHITE\n",
       "Hollywood Institute of Beauty Careers-West Palm Beach     UGDS_HISP\n",
       "Length: 1042, dtype: object"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college_black = college_ugds[highest_percentage_race == 'UGDS_BLACK'] # 找到UGDS_BLACK是最大值的行\n",
    "college_black = college_black.drop('UGDS_BLACK', axis='columns') # 删除UGDS_BLACK列\n",
    "college_black.idxmax(axis='columns') # 每行哪一列的值最大"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 扩展内容，关于.cumsum().cumsum()案例的详解"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = pd.Series(index=list('abcde'), data=[5, 4, 3, 2, 1])\n",
    "s2 = pd.Series(index=list('abcde'), data=[1, 3, 5, 7, -1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(columns = ['c1', 'c2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>c1</th>\n",
       "      <th>c2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>1</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   c1  c2\n",
       "a   5   1\n",
       "b   4   3\n",
       "c   3   5\n",
       "d   2   7\n",
       "e   1  -1"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['c1'] = s1\n",
    "df['c2'] = s2\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_053b881f_b6be_11eb_be0a_548d5ad1d930row0_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_053b881f_b6be_11eb_be0a_548d5ad1d930row3_col1 {\n",
       "            background-color:  yellow;\n",
       "        }</style><table id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >c1</th>        <th class=\"col_heading level0 col1\" >c2</th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930level0_row0\" class=\"row_heading level0 row0\" >a</th>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row0_col0\" class=\"data row0 col0\" >5</td>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row0_col1\" class=\"data row0 col1\" >1</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930level0_row1\" class=\"row_heading level0 row1\" >b</th>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row1_col0\" class=\"data row1 col0\" >4</td>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row1_col1\" class=\"data row1 col1\" >3</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930level0_row2\" class=\"row_heading level0 row2\" >c</th>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row2_col0\" class=\"data row2 col0\" >3</td>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row2_col1\" class=\"data row2 col1\" >5</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930level0_row3\" class=\"row_heading level0 row3\" >d</th>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row3_col0\" class=\"data row3 col0\" >2</td>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row3_col1\" class=\"data row3 col1\" >7</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930level0_row4\" class=\"row_heading level0 row4\" >e</th>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row4_col0\" class=\"data row4 col0\" >1</td>\n",
       "                        <td id=\"T_053b881f_b6be_11eb_be0a_548d5ad1d930row4_col1\" class=\"data row4 col1\" >-1</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x123b38b0>"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.style.highlight_max(axis='rows') # 沿着行的方向标记每行的max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_053e4563_b6be_11eb_b9b4_548d5ad1d930row0_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_053e4563_b6be_11eb_b9b4_548d5ad1d930row1_col0 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_053e4563_b6be_11eb_b9b4_548d5ad1d930row2_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_053e4563_b6be_11eb_b9b4_548d5ad1d930row3_col1 {\n",
       "            background-color:  yellow;\n",
       "        }    #T_053e4563_b6be_11eb_b9b4_548d5ad1d930row4_col0 {\n",
       "            background-color:  yellow;\n",
       "        }</style><table id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >c1</th>        <th class=\"col_heading level0 col1\" >c2</th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930level0_row0\" class=\"row_heading level0 row0\" >a</th>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row0_col0\" class=\"data row0 col0\" >5</td>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row0_col1\" class=\"data row0 col1\" >1</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930level0_row1\" class=\"row_heading level0 row1\" >b</th>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row1_col0\" class=\"data row1 col0\" >4</td>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row1_col1\" class=\"data row1 col1\" >3</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930level0_row2\" class=\"row_heading level0 row2\" >c</th>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row2_col0\" class=\"data row2 col0\" >3</td>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row2_col1\" class=\"data row2 col1\" >5</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930level0_row3\" class=\"row_heading level0 row3\" >d</th>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row3_col0\" class=\"data row3 col0\" >2</td>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row3_col1\" class=\"data row3 col1\" >7</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930level0_row4\" class=\"row_heading level0 row4\" >e</th>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row4_col0\" class=\"data row4 col0\" >1</td>\n",
       "                        <td id=\"T_053e4563_b6be_11eb_b9b4_548d5ad1d930row4_col1\" class=\"data row4 col1\" >-1</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x1243bb68>"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.style.highlight_max(axis='columns') # 沿着列的方向标记每行的max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>c1</th>\n",
       "      <th>c2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      c1     c2\n",
       "a   True  False\n",
       "b  False  False\n",
       "c  False  False\n",
       "d  False   True\n",
       "e  False  False"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mask = df.eq(df.max()) # 可以找到列上的最大值在哪一行\n",
    "mask"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>c1</th>\n",
       "      <th>c2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   c1  c2\n",
       "a   1   0\n",
       "b   1   0\n",
       "c   1   0\n",
       "d   1   1\n",
       "e   1   1"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c1 = mask.cumsum()\n",
    "c1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>c1</th>\n",
       "      <th>c2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   c1  c2\n",
       "a   1   0\n",
       "b   2   0\n",
       "c   3   0\n",
       "d   4   1\n",
       "e   5   2"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c2 = c1.cumsum() # 两次cumsum后还是1的就是该列最大值第一次出现的行！\n",
    "c2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a     True\n",
       "b    False\n",
       "c    False\n",
       "d     True\n",
       "e    False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = c2.eq(1).any(axis='columns') # 列的方向，即每一行有一个等于1就设置为True。Series类型。\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['a', 'd'], dtype='object')"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[lambda x: x].index # 返回值为True的key"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    c1\n",
       "b    c1\n",
       "c    c2\n",
       "d    c2\n",
       "e    c1\n",
       "dtype: object"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = df.idxmax(axis='columns') # 每一行最大值所在列\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "mask = df.eq(df.max(axis='rows'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "c1    True\n",
       "c2    True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = mask.cumsum().cumsum().any(axis='rows') # 没啥意义，因为每列一定会有一个最大值。\n",
    "c"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
